/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package navegador;

import java.io.IOException;
import java.net.UnknownHostException;

/**
 *
 * @author SergioPeres
 */
public class NavegadorJar {

    public NavegadorJar() {}
 
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Parametro par = new Parametro();
        
        if (par.setParametros(args)) {
        
            UriRawContent uriRawContent = new UriRawContent(par);
//             String urlParameters;
//            try {
//                urlParameters = "fName=" + URLEncoder.encode("nome", "UTF-8") +
//                        "&lName=" + URLEncoder.encode("nada", "UTF-8");
//                System.out.println("-- "+uriRawContent.excutePost("http://localhost:8081/pagina.html",urlParameters)+"\n++++++++++");
//            } catch (UnsupportedEncodingException ex) {
//                Logger.getLogger(NavegadorJar.class.getName()).log(Level.SEVERE, null, ex);
//            }
            
            try {
                System.out.println(uriRawContent.getURIRawContent());
            } catch (UnknownHostException e) {
                System.out.println("Host desconhecido!" + e);
            } catch (IOException e) {
                System.out.println("Erro de entrada e saída!" + e);
            }
        } else {
            try {
                Runtime.getRuntime().exec("nav/navegador.net.exe");
            } catch (IOException ex) {
                System.out.println("Erro ao tentar abrir a interfaze do navegador!!!");
            }
        }
    }
    
}
